import { Controller, Get, Post, Body, Query } from '@nestjs/common';
import { FileService } from './file.service';

@Controller('file')
export class FileController {
  constructor(private readonly fileService: FileService) {}

  @Post('write')
  writeFile(
    @Body('data') data: string,
    @Body('fileName') fileName: string,
  ): string {
    this.fileService.writeFile(data, fileName);
    return 'Data written to file';
  }

  @Get('read')
  readFile(@Query('fileName') fileName: string): string {
    return this.fileService.readFile(fileName);
  }

  @Get('getAllNFT')
  getAllFilesData(): any[] {
    return this.fileService.getAllData();
  }

  @Get('getAllUsersId')
  getAllUsersData(): any[] {
    return this.fileService.getAllUsers();
  }
}
